package com.xm.xmapp;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.VolleyError;
import com.xm.xmapp.app.MyAppcation;
import com.xm.xmapp.base.BaseActivity;
import com.xm.xmapp.myinterface.DisssmissInterFace;
import com.xm.xmapp.myinterface.GetDataInterFace;
import com.xm.xmapp.request.bean.FeedbackRequest;
import com.xm.xmapp.tools.ScreenUtils;
import com.xm.xmapp.tools.Tools;

public class AppFeedbackActivity extends BaseActivity implements OnClickListener {

	private TextView title;
	private ImageView back, right;
	private EditText edit;
	private TextView pay;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_appfeedback);
		ScreenUtils.setupUI(findViewById(R.id.content), this);
	}

	@Override
	public void initView() {
		title = (TextView) findViewById(R.id.title);
		back = (ImageView) findViewById(R.id.back);
		right = (ImageView) findViewById(R.id.right);
		edit = (EditText) findViewById(R.id.edit);
		pay = (TextView) findViewById(R.id.pay);
	}

	@Override
	public void initData() {
		title.setText("建议反馈");
		right.setVisibility(View.GONE);

	}

	@Override
	public void initEvent() {
		back.setOnClickListener(this);
		pay.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.back:
			finish();
			break;
		case R.id.pay:
			feedbackRequest();
			break;
		default:
			break;
		}
	}

	private void feedbackRequest() {
		FeedbackRequest requestBean = new FeedbackRequest();
		requestBean.app_type = 1;
		requestBean.content = edit.getText().toString();
		promptDialog.dismiss();
		MyAppcation.getMyAppcation().getPostData(this, requestBean, new GetDataInterFace<String>() {

			@Override
			public void onResponse(String response) {
				promptDialog.dismiss();
				Tools.showMessage("谢谢您反馈的意见,我们将会及时跟进并改进。");
				finish();
			}
		}, new DisssmissInterFace() {

			@Override
			public void putError(VolleyError error) {
				promptDialog.dismiss();
			}
		});
	}

}
